<%@ page import="cn.kgc.javaweb.entiy.User" %>
<%@ page import="java.util.ArrayList" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%-- @taglib  指令 --%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>使用jstl展示数据</title>
</head>
<body>

    <%
        User user = new User("jack", 30);
        ArrayList<User> users = new ArrayList<>();
        users.add(user);
        users.add(user);
        users.add(user);
        users.add(user);
        request.setAttribute("users", users);
    %>

<%--jstl+el  数据展示 --%>

    <table border="1" width="100%" >
        <tr>
            <td>序号</td>
            <th>名字</th>
            <th>年龄</th>
        </tr>

<%--        数据迭代--%>
    <c:forEach items="${users}" var="user" varStatus="vs">
        <tr>
            <td>${vs.index+1}</td>
            <td>${user.username}</td>
            <td>${user.age}</td>
        </tr>
    </c:forEach>
    </table>







</body>
</html>
